package com.qf.service.impl;

import com.qf.dao.StudentMapper;
import com.qf.pojo.Student;
import com.qf.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 54110 on 2021/6/22.
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    StudentMapper studentMapper;

    @Override
    public List<Student> findAll() {
        return studentMapper.findAll();
    }

    @Override
    public Student findById(Integer id) {
        return studentMapper.findById(id);
    }

    @Override
    public String insert(Student student) {
        Integer integer = studentMapper.insertStudent(student);
        if (integer>0){
            return "success";

        }else{
            return "fail";
        }

    }

    @Override
    public String update(Student student) {
        Integer integer = studentMapper.updateStudent(student);
        if (integer>0){
            return "success";

        }else{
            return "fail";
        }
    }

    @Override
    public String deleteById(Integer id) {
        Integer integer = studentMapper.deleteById(id);
        if (integer>0){
            return "success";

        }else{
            return "fail";
        }
    }
}
